package bearworker.zxl.dao.mapper.extra;

import org.apache.ibatis.jdbc.SQL;

/**
 * Created by 逍遥的熊 on 2018/2/11.
 */
public class DeliveryExtraSqlProvider {

    public String getOrderPreRecive(){
        return new SQL(){{
            SELECT("a.package_kilo,a.original_price,a.sender_id,b.id,b.province,b.city,b.district,b.recipients_address,b.recipients_name,b.recipients_telephone");
            FROM("delivery_pre_order a,delivery_recipients b");
            WHERE("a.recipients_id = b.id and b.state = 1 and a.sender_id = #{senderId}");
        }}.toString();
    }

    public String getOrdDtlRecive(){
        return new SQL(){{
            SELECT("a.id,a.order_id,a.pre_ord_id,a.recipients_id,a.package_kilo,a.original_price,a.courier_number,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') as showTime,b.user_id,b.recipients_name,b.recipients_telephone,b.province,b.city,b.district,b.recipients_address");
            FROM("delivery_order_details a,delivery_recipients b");
            WHERE("a.recipients_id = b.id and a.order_id = #{orderId}");
            ORDER_BY("a.create_time desc");
        }}.toString();
    }

    public String getPackageByUserId(){
        return new SQL(){{
            SELECT("a.id,a.order_id,a.pre_ord_id,a.recipients_id,a.package_kilo,a.original_price,a.courier_number,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') as showTime,b.user_id,b.recipients_name,b.recipients_telephone,b.province,b.city,b.district,b.recipients_address");
            FROM("delivery_order_details a,delivery_recipients b,delivery_order c");
            WHERE("a.recipients_id = b.id and a.order_id = c.id and c.state = 3 and b.user_id = #{userId}");
            ORDER_BY("a.create_time desc");
        }}.toString();
    }

    public String getOrdsByState(){
        return new SQL(){
            {
                SELECT("a.id,a.order_no,a.original_price,DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') as ord_time,b.sender_name,b.sender_telephone,b.province,b.city,b.district,b.sender_address,a.state");
                FROM("delivery_order a,delivery_sender b");
                WHERE("a.sender_id = b.id and a.state = #{state}");
                ORDER_BY("a.id desc");
            }
        }.toString();
    }
}
